package concurrent.threadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


public class ExecutorsTest {

    static ExecutorService executorService = Executors.newFixedThreadPool(1);

    public static void main(String[] args) throws InterruptedException {

        for (int i = 0; i < 2; i++) {
            executorService.submit(() -> {
                System.out.println("-->> " + Thread.currentThread().getName());
                throw new RuntimeException("error");
            });
            Thread.sleep(1000);
        }

        System.out.println("--- execute");
        Thread.sleep(1000);
        for (int i = 0; i < 2; i++) {
            executorService.execute(() -> {
                System.out.println("-->> " + Thread.currentThread().getName());
                throw new RuntimeException("error");
            });
            Thread.sleep(1000);
        }
    }
}
